﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataSetEsquemaAppCeiiTableAdapters;

/// <summary>
/// Descripción breve de CartaBLL
/// </summary>
public class CartaBLL
{
	public CartaBLL(){}

    //conexion con base de datos EscorpiusTour
    private CARTA_PRESTAMOTableAdapter _cartaAdapter = null;
    protected CARTA_PRESTAMOTableAdapter Adapter
    {
        get
        {
            if (_cartaAdapter == null)
                _cartaAdapter = new CARTA_PRESTAMOTableAdapter();

            return _cartaAdapter;
        }
    }

    [System.ComponentModel.DataObjectMethodAttribute
    (System.ComponentModel.DataObjectMethodType.Select, true)]
    public DataSetEsquemaAppCeii.CARTA_PRESTAMODataTable selectById(int id)
    {
        return Adapter.GetDataById(id);
    }
    
    [System.ComponentModel.DataObjectMethodAttribute
    (System.ComponentModel.DataObjectMethodType.Insert, true)]
    public int insert(int usr_rut, int lug_id, int usu_usr_rut, int lug_lug_id, int rut_ben, DateTime fecha_ini_carta, DateTime fecha_fin_data, string comentario_carta)
    {
        int filas_afectadas = Adapter.Insert(usr_rut, lug_id, usu_usr_rut, lug_lug_id, rut_ben, fecha_ini_carta, fecha_fin_data, comentario_carta);
        if (filas_afectadas == 0) return 0;
        else return 1;
    }
    [System.ComponentModel.DataObjectMethodAttribute
    (System.ComponentModel.DataObjectMethodType.Select, true)]
    public int max_id()
    {
        decimal? ret = Adapter.MaxQuery();
        int ret3 = int.Parse(ret.ToString());
        return ret3;
    }
    [System.ComponentModel.DataObjectMethodAttribute
    (System.ComponentModel.DataObjectMethodType.Update, true)]
    public int confirm(int rut_c, int id_carta)
    {
        int filas_afectadas = Adapter.UpdateQueryConfirmar(rut_c, id_carta);
        if (filas_afectadas == 0) return 0;
        else return 1;
    }

}
